package com.explorer.ider.bootguide.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;

import com.explorer.ider.bootguide.MainActivity;
import com.explorer.ider.bootguide.R;

/**
 * Created by Eric on 2016/9/5.
 */
public class FragmentWelcome extends Fragment{

    private View views;
    private Button finishButton;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (views == null){
            views = inflater.inflate(R.layout.fragment_welcome, container,false);
            initView();
        }
        return views;
    }

    private void initView() {
        final Animation mAnimationIn , mAnimationOut;
        mAnimationIn = AnimationUtils.loadAnimation(getActivity(), R.anim.view_focus_animation_in);
        mAnimationOut = AnimationUtils.loadAnimation(getActivity(),R.anim.view_focus_animation_out);
        finishButton = (Button) views.findViewById(R.id.id_welcome_finish_button);
        finishButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setAction(MainActivity.ACTION_TO_FINISH);
                getActivity().sendBroadcast(intent);
            }
        });
        finishButton.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus){
//                    finishButton.setAnimation(mAnimationIn);
                }else {
//                    finishButton.setAnimation(mAnimationOut);
                }
            }
        });
    }


}
